import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.*;
import java.sql.SQLOutput;
import java.util.Scanner;
import java.util.concurrent.Semaphore;

public class Thread60 {
    public static void main(String[] args)throws IOException {
        try(InputStream inputStream=new FileInputStream("c:/Intel/text.txt"))
        {
            Scanner scanner=new Scanner(inputStream);
            while(scanner.hasNext()) {
                String s = scanner.next();
                System.out.println(s);
            }


        }
    }
    public static void main34(String[] args) {
        Scanner scaner=new Scanner(System.in);//System.in其实就是一个输入流对象

    }
    public static void main32(String[] args) {
        File file=new File("c:/Intel/big/xiaoLog/text1.txt");
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main31(String[] args) {
        File file=new File("c:/Intel/big/xiuli/text1.txt");
        try(Writer write=new FileWriter(file))
        {
            write.write("Log");


        }catch(IOException e)
        {
            e.printStackTrace();
        }
    }
    public static void main45(String[] args)throws IOException {
        File file=new File("c:/Intel/Logs/Log.txt");
        file.createNewFile();
    }
    public static void main25(String[] args) {
        File file=new File("c:/MyDrivers/update/text.txt");
        System.out.println(file.isFile());
    }
    public static void main24(String[] args)throws IOException {

        File file=new File("c:/Intel/Logs/cat.png");
        File file2=new File("c:/Intel/Logs/pig.jpg");
        file.renameTo(file2);
        //file.createNewFile();
        //System.out.println(file.isFile());
    }
    public static void main23(String[] args) {
        File file=new File("c:/Intel/Logs/money.jpg");
        System.out.println(file.isFile());
        File file2=new File("c:/Intel/Logs/cat.jpg");
        //file.renameTo(file2);

    }

    public static void main20(String[] args) {
        try(InputStream inputStream=new FileInputStream("c:/Intel/Logs/"))
        {


        }catch(IOException e)
        {
            e.printStackTrace();
        }
    }
    public static void main19(String[] args) {
        try(OutputStream outputStream=new FileOutputStream("c:/Intel/text.txt"))
        {
            outputStream.write('l');
            outputStream.write('o');
            outputStream.write('v');
            outputStream.write('e');
        }catch(IOException e)
        {
            e.printStackTrace();
        }
    }
    public static void main18(String[] args) {
        try(Writer write=new FileWriter("c:/Intel/text.txt"))
        {

            write.write("中");
            write.write("国");
            write.write("万");


        }catch(IOException e)
        {
            e.printStackTrace();
        }

    }
    public static void main333(String[] args)throws IOException {
        try (Writer write = new FileWriter("c:/Intel/text.txt")) {

            write.write("宝贝");
            write.flush();
        }
    }




    public static void main16(String[] args)
    {
        try(Reader reader=new FileReader("c:/Intel/text.txt"))
        {
            while(true) {
                int a = reader.read();
                if (a == -1) {
                    break;
                }
                System.out.println((char)a);
            }

        }catch(IOException e)
        {
            e.printStackTrace();
        }
    }


    public static void main9109(String[] args)throws IOException {
        try(InputStream inputStream=new FileInputStream("c:/MyDrivers/pig.jpg"))
        {
            while(true)
            {
                byte[]buffer=new byte[1024];//每次尽力读1024
                int length=inputStream.read(buffer);//返回读取的字节数
                System.out.println(length);
                if(length==-1)
                {
                    break;
                }
                //for(int i=0;i<length;i++)//文件读取的内容
                //{
                   // System.out.printf("%x\n",(byte)buffer[i]);
               // }

            }
        }
    }
    public static void main14(String[] args)throws IOException {
        try(OutputStream outputStream=new FileOutputStream("c:/Intel/text.txt"))
        {
            outputStream.write(97);
            outputStream.write(98);
            outputStream.write(99);
            outputStream.write(100);
            outputStream.write(101);
            outputStream.write(102);
        }

    }
    public static void main211(String[] args)throws IOException {
        try(Reader reader=new FileReader("c:/Intel/text.txt")) {
            while (true) {
                int a = reader.read();
                if (a == -1) {
                    break;
                }
                System.out.println((char)a);
            }
        }

    }

    public static void main123(String[] args)throws IOException {

        try (OutputStream outputStream = new FileOutputStream("c:/Intel/text2.txt")) {
            outputStream.write('h');
            outputStream.write('e');


        }
    }
   public static void main112(String[] args)throws IOException {
       try (InputStream inputStream = new FileInputStream("c:/Intel/text2.txt")) {
           while (true) {
               int a = inputStream.read();

               if (a == -1)//表示读取到文件末尾
               {
                   break;
               }
               System.out.printf("%x" + " ", (byte) a);//实际上每次读一个字节我们再强转成byte
           }


       }
   }

    public static void main144(String[] args)throws IOException {
        File file=new File("c:/Intel/text2.txt");
        file.createNewFile();
    }

    public static void main10(String[] args)throws IOException {
        File file=new File("c:/Intel/text.txt");
        file.createNewFile();
    }
    public static void main9(String[] args) throws IOException {
        File file=new File("c:/MyDrivers/update/text.txt");

        file.createNewFile();

    }
    public static void main101(String[] args) {
        File file=new File("./in/aaa/bbb");
        file.mkdirs();
    }

    public static void main7(String[] args) {
        File file=new File("./text.txt");
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main100(String[] args) {
        File file=new File("d:/123/giteedemo/util11/in");
        file.mkdir();
    }
    public static void main5(String[] args) {
        //File file=new File("c:/Intel/big");
        //file.mkdir();
        File file=new File("c:/Intel/big/xiuli/longxiang");
        file.mkdir();
    }

    public static void main4(String[] args)throws IOException {
        File file=new File("./pig.jpg");
        System.out.println(file.exists());//判断文件是否存在
        System.out.println(file.getName());//文件名
        System.out.println(file.getParent());
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());


    }
    public static void main111(String[] args)throws IOException {
        File file = new File("c:/intel/Logs/cat.txt");//这个文件不一定是真实存在的
        System.out.println(file.getName());
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());//文件的绝对路径
        System.out.println(file.getParent());//除去文件名的路径
        System.out.println(file.isFile());//判断是不是文件
        System.out.println(file.isDirectory());//判断是不是目录
        file.createNewFile();//创建这样的一个文件出来
        System.out.println(file.isFile());
        //file.delete();//删除改文件
    }






    public static void main2(String[] args) {
        File file=new File("c:/intel/Logs");
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
    }
    public static void main1(String[] args) {
        File file=new File("c:/END");//这个文件不一定存在
        System.out.println(file.exists());
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
    }
}
